package saobracaj;

import java.awt.Color;
import java.awt.Graphics;
import saobracaj.Raskrsnica;

import java.util.ArrayList;
import java.util.Random;

import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 
 * @author yogi
 */

public class RaskrsnicaGUI extends javax.swing.JFrame {

	private static RaskrsnicaGUI singleton = null;
	private Raskrsnica rask;

	/**
	 * Creates new form designFrame
	 */

	public static RaskrsnicaGUI dohvatiRaskrsnicu() {
		if (singleton == null)
			singleton = new RaskrsnicaGUI();
		return singleton;
	}

	private RaskrsnicaGUI() {

		(rask = new Raskrsnica()).start();
		initComponents();
		

	}
        
	public Raskrsnica dohvatiRask(){
			return rask;
	}
        public void paint(Graphics g){
            
            super.paint(g);
          /*  if (rask.getPsever1().size() != 0) 
                    for(int i = 0; i<rask.getPsever1().size(); i++)
                    	rask.getPsever1().get(i).paint();
            if (rask.getPsever2().size() != 0) 
                for(int i = 0; i<rask.getPsever2().size(); i++)
                		rask.getPsever2().get(i).paint();
            if (rask.getPistok1().size() != 0) 
                for(int i = 0; i<rask.getPistok1().size(); i++)
                		rask.getPistok1().get(i).paint();
            if (rask.getPistok2().size() != 0) 
                for(int i = 0; i<rask.getPistok2().size(); i++)
                	rask.getPistok2().get(i).paint();
            if (rask.getPjug1().size() != 0) 
        		for(int i = 0; i<rask.getPjug1().size(); i++)
            		rask.getPjug1().get(i).paint();
            if (rask.getPjug2().size() != 0) 
            	for(int i = 0; i<rask.getPjug2().size(); i++)
            		rask.getPjug2().get(i).paint();
            if (rask.getPzapad1().size() != 0) 
                   for(int i = 0; i<rask.getPzapad1().size(); i++)
        		rask.getPzapad1().get(i).paint();
            if (rask.getPzapad2().size() != 0) 
                    for(int i = 0; i<rask.getPzapad2().size(); i++)
        		rask.getPzapad2().get(i).paint();*/
            
            
            
            
            //TODO za svakog pesaka iscrtati!!!!
            
        }
        
	public void repaint() {
                jPanel1.requestFocus();
		//if (rask.getPsever1().size() != 0) 
		//		rask.getPsever1().get(0).paint();
		if (rask.getSeverS()[0].crvenoZuto()) {
                    semaphoreNorthRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-md.png")));
		}
		
		else
			switch (rask.getSeverS()[0].dohvatiSvetlo()) {
			case 0:
				semaphoreNorthRight.setIcon(new javax.swing.ImageIcon(getClass()
						.getResource(
								"/images/traffic-semaphore-no-light-md.png")));
				break;
			case 1:
				semaphoreNorthRight.setIcon(new javax.swing.ImageIcon(getClass()
						.getResource(
								"/images/traffic-semaphore-red-light-md.png")));
				break;
			case 2:
				semaphoreNorthRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-md.png")));
				break;
			case 3:
				semaphoreNorthRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-md.png")));
			}
		if (rask.getSeverS()[1].crvenoZuto()) {
                    semaphoreNorthForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-md.png")));
		
		}
		// // TODO dodati crveno-zutu sliku
		else
			switch (rask.getSeverS()[1].dohvatiSvetlo()) {
			case 0:
				semaphoreNorthForward.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-no-light-md.png")));
				break;
			case 1:
				semaphoreNorthForward.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-red-light-md.png")));
				break;
			case 2:
				semaphoreNorthForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-md.png")));
				break;
			case 3:
				semaphoreNorthForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-md.png")));
			}

		if (rask.getSeverS()[2].crvenoZuto()) {
                    semaphoreNorthLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-md.png")));
		
		}
		// // TODO dodati crveno-zutu sliku
		else
			switch (rask.getSeverS()[2].dohvatiSvetlo()) {
			case 0:
				semaphoreNorthLeft.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-no-light-md.png")));
				break;
			case 1:
				semaphoreNorthLeft.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-red-light-md.png")));
				break;
			case 2:
				semaphoreNorthLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-md.png")));
				break;
			case 3:
				semaphoreNorthLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-md.png")));
			}

		if (rask.getJugS()[0].crvenoZuto()) {
                    semaphoreSouthLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-md.png")));
		
		}
		// TODO dodati crveno-zutu sliku
		else
			switch (rask.getJugS()[0].dohvatiSvetlo()) {
			case 0:
				semaphoreSouthLeft.setIcon(new javax.swing.ImageIcon(getClass()
						.getResource(
								"/images/traffic-semaphore-no-light-md.png")));
				break;
			case 1:
				semaphoreSouthLeft.setIcon(new javax.swing.ImageIcon(getClass()
						.getResource(
								"/images/traffic-semaphore-red-light-md.png")));
				break;
			case 2:
				semaphoreSouthLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-md.png")));
				break;
			case 3:
				semaphoreSouthLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-md.png")));
			}

		if (rask.getJugS()[1].crvenoZuto()) {
                    semaphoreSouthForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-md.png")));
		// 
		}
		// TODO dodati crveno-zutu sliku
		else
			switch (rask.getJugS()[1].dohvatiSvetlo()) {
			case 0:
				semaphoreSouthForward.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-no-light-md.png")));
				break;
			case 1:
				semaphoreSouthForward.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-red-light-md.png")));
				break;
			case 2:
				semaphoreSouthForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-md.png")));
				break;
			case 3:
				semaphoreSouthForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-md.png")));
			}

		if (rask.getJugS()[2].crvenoZuto()) {
                    semaphoreSouthRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-md.png")));
		// 
		}
		// TODO dodati crveno-zutu sliku
		else
			switch (rask.getJugS()[2].dohvatiSvetlo()) {
			case 0:
				semaphoreSouthRight.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-no-light-md.png")));
				break;
			case 1:
				semaphoreSouthRight.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-red-light-md.png")));
				break;
			case 2:
				semaphoreSouthRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-md.png")));
				break;
			case 3:
				semaphoreSouthRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-md.png")));
			}

		if (rask.getIstokS()[0].crvenoZuto()) {
                    semaphoreEastLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-mdR.png")));
		
		}
		// // TODO dodati crveno-zutu sliku
		else
			switch (rask.getIstokS()[0].dohvatiSvetlo()) {
			case 0:
				semaphoreEastLeft.setIcon(new javax.swing.ImageIcon(getClass()
						.getResource(
								"/images/traffic-semaphore-no-light-mdR.png")));
				break;
			case 1:
				semaphoreEastLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-red-light-mdR.png")));
				break;
			case 2:
				semaphoreEastLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-mdR.png")));
				break;
			case 3:
				semaphoreEastLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-mdR.png")));
			}

		if (rask.getIstokS()[1].crvenoZuto()) {
                    semaphoreEastForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-mdR.png")));
		
		}
		// // TODO dodati crveno-zutu sliku
		else
			switch (rask.getIstokS()[1].dohvatiSvetlo()) {
			case 0:
				semaphoreEastForward.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-no-light-mdR.png")));
				break;
			case 1:
				semaphoreEastForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-red-light-mdR.png")));
				break;
			case 2:
				semaphoreEastForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-mdR.png")));
				break;
			case 3:
				semaphoreEastForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-mdR.png")));
			}

		if (rask.getIstokS()[2].crvenoZuto()) {
                    semaphoreEastRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-mdR.png")));
		
		}
		// // TODO dodati crveno-zutu sliku
		else
			switch (rask.getIstokS()[2].dohvatiSvetlo()) {
			case 0:
				semaphoreEastRight.setIcon(new javax.swing.ImageIcon(getClass()
						.getResource(
								"/images/traffic-semaphore-no-light-mdR.png")));
				break;
			case 1:
				semaphoreEastRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-red-light-mdR.png")));
				break;
			case 2:
				semaphoreEastRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-mdR.png")));
				break;
			case 3:
				semaphoreEastRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-mdR.png")));
			}

		if (rask.getZapadS()[0].crvenoZuto()) {
                    semaphoreWestLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-mdL.png")));
		
		}
		// // TODO dodati crveno-zutu sliku
		else
			switch (rask.getZapadS()[0].dohvatiSvetlo()) {
			case 0:
				semaphoreWestLeft.setIcon(new javax.swing.ImageIcon(getClass()
						.getResource(
								"/images/traffic-semaphore-no-light-mdL.png")));
				break;
			case 1:
				semaphoreWestLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-red-light-mdL.png")));
				break;
			case 2:
				semaphoreWestLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-mdL.png")));
				break;
			case 3:
				semaphoreWestLeft
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-mdL.png")));
			}

		if (rask.getZapadS()[1].crvenoZuto()) {
                    semaphoreWestForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-mdL.png")));
		
		}
		// // TODO dodati crveno-zutu sliku
		else
			switch (rask.getZapadS()[1].dohvatiSvetlo()) {
			case 0:
				semaphoreWestForward.setIcon(new javax.swing.ImageIcon(
						getClass().getResource(
								"/images/traffic-semaphore-no-light-mdL.png")));
				break;
			case 1:
				semaphoreWestForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-red-light-mdL.png")));
				break;
			case 2:
				semaphoreWestForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-mdL.png")));
				break;
			case 3:
				semaphoreWestForward
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-mdL.png")));
			}

		if (rask.getZapadS()[2].crvenoZuto()) {
                    semaphoreWestRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-red-yellow-light-mdL.png")));
		
		}
		// // TODO dodati crveno-zutu sliku
		else
			switch (rask.getZapadS()[2].dohvatiSvetlo()) {
			case 0:
				semaphoreWestRight.setIcon(new javax.swing.ImageIcon(getClass()
						.getResource(
								"/images/traffic-semaphore-no-light-mdL.png")));
				break;
			case 1:
				semaphoreWestRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-red-light-mdL.png")));
				break;
			case 2:
				semaphoreWestRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-yellow-light-mdL.png")));
				break;
			case 3:
				semaphoreWestRight
						.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/traffic-semaphore-green-light-mdL.png")));
			}
                
                switch(rask.getSeverPes().dohvatiSvetlo()) {
                    case 0: pedestriansNorth.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciNLleft.jpg")));//FIXME ovde treba iskljuceno
                            break;
                    case 1: pedestriansNorth.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciCrvenaL.png")));
                            break;
                    case 3: pedestriansNorth.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciZelenaL.png")));
                            break;
                }
                
                 switch(rask.getJugPes().dohvatiSvetlo()) {
                    case 0: pedestriansSouth.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciNLright.jpg")));//FIXME ovde treba iskljuceno
                            break;
                    case 1: pedestriansSouth.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciCrvenaR.png")));
                            break;
                    case 3: pedestriansSouth.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciZelenaR.png")));
                            break;
                }
                
                   switch(rask.getIstokPes().dohvatiSvetlo()) {
                    case 0: pedestriansEast.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciNL.jpg")));//FIXME ovde treba iskljuceno
                            break;
                    case 1: pedestriansEast.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciCrvena.png")));
                            break;
                    case 3: pedestriansEast.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciZelena.png")));
                            break;
                }
                   
                  switch(rask.getZapadPes().dohvatiSvetlo()) {
                    case 0: pedestriansWest.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciNLdown.png")));//FIXME ovde treba iskljuceno
                            break;
                    case 1: pedestriansWest.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciCrvenaD.png")));
                            break;
                    case 3: pedestriansWest.setIcon(new javax.swing.ImageIcon(
								getClass()
										.getResource(
												"/images/pesaciZelenaD.png")));
                            break;
                }
                 

		super.repaint();
	}
        
        

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new javax.swing.JPanel();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        semaphoreNorthRight = new javax.swing.JLabel();
        semaphoreNorthForward = new javax.swing.JLabel();
        semaphoreNorthLeft = new javax.swing.JLabel();
        semaphoreSouthLeft = new javax.swing.JLabel();
        semaphoreSouthForward = new javax.swing.JLabel();
        semaphoreSouthRight = new javax.swing.JLabel();
        semaphoreEastRight = new javax.swing.JLabel();
        semaphoreEastForward = new javax.swing.JLabel();
        semaphoreEastLeft = new javax.swing.JLabel();
        semaphoreWestLeft = new javax.swing.JLabel();
        semaphoreWestForward = new javax.swing.JLabel();
        semaphoreWestRight = new javax.swing.JLabel();
        pedestriansSouth = new javax.swing.JLabel();
        timerSouth = new javax.swing.JLabel();
        pedestriansWest = new javax.swing.JLabel();
        timerWest = new javax.swing.JLabel();
        pedestriansEast = new javax.swing.JLabel();
        timerEast = new javax.swing.JLabel();
        pedestriansNorth = new javax.swing.JLabel();
        timerNorth = new javax.swing.JLabel();
        addPesakN1 = new javax.swing.JButton();
        addPesakN2 = new javax.swing.JButton();
        addPesakE1 = new javax.swing.JButton();
        addPesakE2 = new javax.swing.JButton();
        addPesakS1 = new javax.swing.JButton();
        addPesakS2 = new javax.swing.JButton();
        addPesakW1 = new javax.swing.JButton();
        addPesakW2 = new javax.swing.JButton();
        tasterS = new javax.swing.JButton();
        testerI = new javax.swing.JButton();
        tasterJ = new javax.swing.JButton();
        tasterZ = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jButton20 = new javax.swing.JButton();
        jButton24 = new javax.swing.JButton();
        jButton25 = new javax.swing.JButton();
        jButton26 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jPanel1KeyPressed(evt);
            }
        });
        jPanel1.setLayout(new java.awt.GridBagLayout());

        semaphoreNorthRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreNorthRight.setAlignmentX(0.5F);
        semaphoreNorthRight.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreNorthRight.setBounds(64, 5, 30, 70);
        jLayeredPane1.add(semaphoreNorthRight, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreNorthForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreNorthForward.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreNorthForward.setBounds(105, 5, 30, 70);
        jLayeredPane1.add(semaphoreNorthForward, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreNorthLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreNorthLeft.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreNorthLeft.setBounds(145, 5, 30, 70);
        jLayeredPane1.add(semaphoreNorthLeft, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreSouthLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreSouthLeft.setAlignmentX(0.5F);
        semaphoreSouthLeft.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreSouthLeft.setBounds(363, 430, 30, 70);
        jLayeredPane1.add(semaphoreSouthLeft, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreSouthForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreSouthForward.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreSouthForward.setBounds(404, 430, 30, 70);
        jLayeredPane1.add(semaphoreSouthForward, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreSouthRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreSouthRight.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-md.png"))); // NOI18N
        semaphoreSouthRight.setBounds(444, 430, 30, 70);
        jLayeredPane1.add(semaphoreSouthRight, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreEastRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdR.png"))); // NOI18N
        semaphoreEastRight.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdR.png"))); // NOI18N
        semaphoreEastRight.setBounds(444, 47, 70, 30);
        jLayeredPane1.add(semaphoreEastRight, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreEastForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdR.png"))); // NOI18N
        semaphoreEastForward.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdR.png"))); // NOI18N
        semaphoreEastForward.setBounds(444, 88, 70, 30);
        jLayeredPane1.add(semaphoreEastForward, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreEastLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdR.png"))); // NOI18N
        semaphoreEastLeft.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdR.png"))); // NOI18N
        semaphoreEastLeft.setBounds(444, 128, 70, 30);
        jLayeredPane1.add(semaphoreEastLeft, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreWestLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdL.png"))); // NOI18N
        semaphoreWestLeft.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdL.png"))); // NOI18N
        semaphoreWestLeft.setBounds(12, 337, 70, 30);
        jLayeredPane1.add(semaphoreWestLeft, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreWestForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdL.png"))); // NOI18N
        semaphoreWestForward.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdL.png"))); // NOI18N
        semaphoreWestForward.setBounds(12, 378, 70, 30);
        jLayeredPane1.add(semaphoreWestForward, javax.swing.JLayeredPane.DEFAULT_LAYER);

        semaphoreWestRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdL.png"))); // NOI18N
        semaphoreWestRight.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/traffic-semaphore-no-light-mdL.png"))); // NOI18N
        semaphoreWestRight.setBounds(12, 418, 70, 30);
        jLayeredPane1.add(semaphoreWestRight, javax.swing.JLayeredPane.DEFAULT_LAYER);

        pedestriansSouth.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pesaciZelenaR.png"))); // NOI18N
        pedestriansSouth.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pesaciCrvena.png"))); // NOI18N
        pedestriansSouth.setBounds(344, 390, 50, 30);
        jLayeredPane1.add(pedestriansSouth, javax.swing.JLayeredPane.DEFAULT_LAYER);

        timerSouth.setBackground(new java.awt.Color(0, 0, 0));
        timerSouth.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        timerSouth.setForeground(new java.awt.Color(255, 51, 51));
        timerSouth.setText("130");
        timerSouth.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 51, 255)));
        timerSouth.setFocusable(false);
        timerSouth.setOpaque(true);
        timerSouth.setBounds(360, 370, 30, 18);
        jLayeredPane1.add(timerSouth, javax.swing.JLayeredPane.DEFAULT_LAYER);

        pedestriansWest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pesaciZelenaD.png"))); // NOI18N
        pedestriansWest.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pesaciCrvenaL.png"))); // NOI18N
        pedestriansWest.setBounds(85, 317, 30, 50);
        jLayeredPane1.add(pedestriansWest, javax.swing.JLayeredPane.DEFAULT_LAYER);

        timerWest.setBackground(new java.awt.Color(0, 0, 0));
        timerWest.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        timerWest.setForeground(new java.awt.Color(255, 51, 51));
        timerWest.setText("130");
        timerWest.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 51, 255)));
        timerWest.setFocusable(false);
        timerWest.setOpaque(true);
        timerWest.setBounds(117, 340, 30, 18);
        jLayeredPane1.add(timerWest, javax.swing.JLayeredPane.DEFAULT_LAYER);

        pedestriansEast.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pesaciZelena.png"))); // NOI18N
        pedestriansEast.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pesaciCrvenaR.png"))); // NOI18N
        pedestriansEast.setBounds(412, 120, 30, 50);
        jLayeredPane1.add(pedestriansEast, javax.swing.JLayeredPane.DEFAULT_LAYER);

        timerEast.setBackground(new java.awt.Color(0, 0, 0));
        timerEast.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        timerEast.setForeground(new java.awt.Color(255, 51, 51));
        timerEast.setText("130");
        timerEast.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 51, 255)));
        timerEast.setFocusable(false);
        timerEast.setOpaque(true);
        timerEast.setBounds(380, 130, 30, 18);
        jLayeredPane1.add(timerEast, javax.swing.JLayeredPane.DEFAULT_LAYER);

        pedestriansNorth.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pesaciZelenaL.png"))); // NOI18N
        pedestriansNorth.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pesaciCrvena.png"))); // NOI18N
        pedestriansNorth.setBounds(131, 78, 50, 30);
        jLayeredPane1.add(pedestriansNorth, javax.swing.JLayeredPane.DEFAULT_LAYER);

        timerNorth.setBackground(new java.awt.Color(0, 0, 0));
        timerNorth.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        timerNorth.setForeground(new java.awt.Color(255, 51, 51));
        timerNorth.setText("130");
        timerNorth.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 51, 255)));
        timerNorth.setFocusable(false);
        timerNorth.setOpaque(true);
        timerNorth.setBounds(135, 110, 30, 18);
        jLayeredPane1.add(timerNorth, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addPesakN1.setText("+");
        addPesakN1.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        addPesakN1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        addPesakN1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPesakN1ActionPerformed(evt);
            }
        });
        addPesakN1.setBounds(165, 120, 20, 20);
        jLayeredPane1.add(addPesakN1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addPesakN2.setText("+");
        addPesakN2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        addPesakN2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPesakN2ActionPerformed(evt);
            }
        });
        addPesakN2.setBounds(343, 110, 20, 20);
        jLayeredPane1.add(addPesakN2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addPesakE1.setText("+");
        addPesakE1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        addPesakE1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPesakE1ActionPerformed(evt);
            }
        });
        addPesakE1.setBounds(380, 150, 20, 20);
        jLayeredPane1.add(addPesakE1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addPesakE2.setText("+");
        addPesakE2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        addPesakE2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPesakE2ActionPerformed(evt);
            }
        });
        addPesakE2.setBounds(380, 317, 20, 20);
        jLayeredPane1.add(addPesakE2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addPesakS1.setText("+");
        addPesakS1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        addPesakS1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPesakS1ActionPerformed(evt);
            }
        });
        addPesakS1.setBounds(343, 350, 20, 20);
        jLayeredPane1.add(addPesakS1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addPesakS2.setText("+");
        addPesakS2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        addPesakS2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPesakS2ActionPerformed(evt);
            }
        });
        addPesakS2.setBounds(165, 350, 20, 20);
        jLayeredPane1.add(addPesakS2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addPesakW1.setText("+");
        addPesakW1.setMargin(new java.awt.Insets(0, 0, 0, 0));
        addPesakW1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPesakW1ActionPerformed(evt);
            }
        });
        addPesakW1.setBounds(125, 317, 20, 20);
        jLayeredPane1.add(addPesakW1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        addPesakW2.setText("+");
        addPesakW2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        addPesakW2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addPesakW2ActionPerformed(evt);
            }
        });
        addPesakW2.setBounds(125, 150, 20, 20);
        jLayeredPane1.add(addPesakW2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tasterS.setText("+");
        tasterS.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        tasterS.setMargin(new java.awt.Insets(0, 0, 0, 0));
        tasterS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tasterSActionPerformed(evt);
            }
        });
        tasterS.setBounds(110, 84, 20, 20);
        jLayeredPane1.add(tasterS, javax.swing.JLayeredPane.DEFAULT_LAYER);

        testerI.setText("+");
        testerI.setMargin(new java.awt.Insets(0, 0, 0, 0));
        testerI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                testerIActionPerformed(evt);
            }
        });
        testerI.setBounds(416, 99, 20, 20);
        jLayeredPane1.add(testerI, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tasterJ.setText("+");
        tasterJ.setMargin(new java.awt.Insets(0, 0, 0, 0));
        tasterJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tasterJActionPerformed(evt);
            }
        });
        tasterJ.setBounds(396, 396, 20, 20);
        jLayeredPane1.add(tasterJ, javax.swing.JLayeredPane.DEFAULT_LAYER);

        tasterZ.setText("+");
        tasterZ.setMargin(new java.awt.Insets(0, 0, 0, 0));
        tasterZ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tasterZActionPerformed(evt);
            }
        });
        tasterZ.setBounds(90, 368, 20, 20);
        jLayeredPane1.add(tasterZ, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton6.setText("+");
        jButton6.setToolTipText("");
        jButton6.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jButton6.setBounds(189, 3, 20, 20);
        jLayeredPane1.add(jButton6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton7.setText("+");
        jButton7.setToolTipText("");
        jButton7.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jButton7.setBounds(217, 3, 20, 20);
        jLayeredPane1.add(jButton7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton8.setText("+");
        jButton8.setToolTipText("");
        jButton8.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jButton8.setBounds(245, 3, 20, 20);
        jLayeredPane1.add(jButton8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton12.setText("+");
        jButton12.setToolTipText("");
        jButton12.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });
        jButton12.setBounds(502, 173, 20, 20);
        jLayeredPane1.add(jButton12, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton13.setText("+");
        jButton13.setToolTipText("");
        jButton13.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });
        jButton13.setBounds(502, 197, 20, 20);
        jLayeredPane1.add(jButton13, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton14.setText("+");
        jButton14.setToolTipText("");
        jButton14.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });
        jButton14.setBounds(502, 222, 20, 20);
        jLayeredPane1.add(jButton14, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton18.setText("+");
        jButton18.setToolTipText("");
        jButton18.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });
        jButton18.setBounds(323, 482, 20, 20);
        jLayeredPane1.add(jButton18, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton19.setText("+");
        jButton19.setToolTipText("");
        jButton19.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });
        jButton19.setBounds(297, 482, 20, 20);
        jLayeredPane1.add(jButton19, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton20.setText("+");
        jButton20.setToolTipText("");
        jButton20.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton20ActionPerformed(evt);
            }
        });
        jButton20.setBounds(271, 482, 20, 20);
        jLayeredPane1.add(jButton20, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton24.setText("+");
        jButton24.setToolTipText("");
        jButton24.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton24.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton24ActionPerformed(evt);
            }
        });
        jButton24.setBounds(7, 292, 20, 20);
        jLayeredPane1.add(jButton24, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton25.setText("+");
        jButton25.setToolTipText("");
        jButton25.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton25.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton25ActionPerformed(evt);
            }
        });
        jButton25.setBounds(7, 268, 20, 20);
        jLayeredPane1.add(jButton25, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton26.setText("+");
        jButton26.setToolTipText("");
        jButton26.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButton26.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton26ActionPerformed(evt);
            }
        });
        jButton26.setBounds(7, 245, 20, 20);
        jLayeredPane1.add(jButton26, javax.swing.JLayeredPane.DEFAULT_LAYER);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        jPanel1.add(jLayeredPane1, gridBagConstraints);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/design.png"))); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        jPanel1.add(jLabel1, gridBagConstraints);

        jButton1.setText("Start");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(65, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 66, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

        private void addPesakN1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPesakN1ActionPerformed
            Random generator = new Random();
            int i = rask.getPsever1().size();
            int n = i / 2;
            rask.dodajPesaka(new Pesak(175 + (i % 2) * 6, 140 + n*6, 0, rask, generator.nextInt(10) + 1), 0);
           // rask.dodajPesaka(new Pesak(160, 160, 0, rask, generator.nextInt(10) + 1), 0);
        }//GEN-LAST:event_addPesakN1ActionPerformed

    private void tasterSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tasterSActionPerformed
        rask.getSeverPes().pritisniTaster();
    }//GEN-LAST:event_tasterSActionPerformed

    private void testerIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_testerIActionPerformed
       rask.getIstokPes().pritisniTaster();
    }//GEN-LAST:event_testerIActionPerformed

    private void tasterJActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tasterJActionPerformed
       rask.getJugPes().pritisniTaster();
    }//GEN-LAST:event_tasterJActionPerformed

    private void tasterZActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tasterZActionPerformed
       rask.getZapadPes().pritisniTaster();
    }//GEN-LAST:event_tasterZActionPerformed

    private void addPesakN2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPesakN2ActionPerformed
             Random generator = new Random();
            int i = rask.getPsever2().size();
            int n = i / 2;
            rask.dodajPesaka(new Pesak(342 + (i % 2) * 6, 135 + n*6 , 1, rask, generator.nextInt(10) + 1), 1);
    }//GEN-LAST:event_addPesakN2ActionPerformed

    private void addPesakE1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPesakE1ActionPerformed
            Random generator = new Random();
            int i = rask.getPistok1().size();
            int n = i / 2;
            rask.dodajPesaka(new Pesak(354 + n*6, 160 + (i % 2) * 6, 2, rask, generator.nextInt(10) + 1), 2);
    }//GEN-LAST:event_addPesakE1ActionPerformed

    private void addPesakE2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPesakE2ActionPerformed
        Random generator = new Random();
            int i = rask.getPistok2().size();
            int n = i / 2;
            rask.dodajPesaka(new Pesak(354 + n*6, 317 + (i % 2) * 6, 3, rask, generator.nextInt(10) + 1), 3);
    }//GEN-LAST:event_addPesakE2ActionPerformed

    private void addPesakS1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPesakS1ActionPerformed
         Random generator = new Random();
            int i = rask.getPjug1().size();
            int n = i / 2;
            rask.dodajPesaka(new Pesak(342 + (i % 2) * 6, 317 + n*6, 4, rask, generator.nextInt(10) + 1), 4);
    }//GEN-LAST:event_addPesakS1ActionPerformed

    private void addPesakS2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPesakS2ActionPerformed
         Random generator = new Random();
            int i = rask.getPjug2().size();
            int n = i / 2;
            rask.dodajPesaka(new Pesak(175 + (i % 2) * 6, 317 + n*6, 5, rask, generator.nextInt(10) + 1), 5);
    }//GEN-LAST:event_addPesakS2ActionPerformed

    private void addPesakW1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPesakW1ActionPerformed
         Random generator = new Random();
            int i = rask.getPzapad1().size();
            int n = i / 2;
            rask.dodajPesaka(new Pesak(168 - n*6, 317 + (i % 2) * 6, 6, rask, generator.nextInt(10) + 1), 6);
    }//GEN-LAST:event_addPesakW1ActionPerformed

    private void addPesakW2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addPesakW2ActionPerformed
         Random generator = new Random();
            int i = rask.getPzapad2().size();
            int n = i / 2;
            rask.dodajPesaka(new Pesak(168 - n*6, 160 + (i % 2) * 6, 7, rask, generator.nextInt(10) + 1), 7);
    }//GEN-LAST:event_addPesakW2ActionPerformed

    

    private void jPanel1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPanel1KeyPressed
       char c  = evt.getKeyChar();
       System.out.println(c);
       if (c == 'u')  rask.getSeverPes().pritisniTaster();
       if (c == 'i')  rask.getIstokPes().pritisniTaster();
       if (c == 'j')  rask.getJugPes().pritisniTaster();
       if (c == 'k')  rask.getZapadPes().pritisniTaster();
       
    }//GEN-LAST:event_jPanel1KeyPressed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        Random generator = new Random();
        int i = rask.kseverD;
		synchronized (rask.kseverD) {
			rask.kseverD++;
		}
        int n = i / 2;
        new Automobil(189, 30 - 21*i, 11, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        Random generator = new Random();
        
        int i = rask.kseverP;
		synchronized (rask.kseverP) {
			rask.kseverP++;
		}
        int n = i / 2;
        new Automobil(217, 30 - 21*i, 12, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        Random generator = new Random();
        int i = rask.kseverL;
		synchronized (rask.kseverL) {
			rask.kseverL++;
		}
        int n = i / 2;
        new Automobil(245, 30 - 21*i, 13, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        Random generator = new Random();
        int i = rask.kistokD;
		synchronized (rask.kistokD) {
			rask.kistokD++;
		}
        int n = i / 2;
        new Automobil(460 + 22*i, 173, 21, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
       Random generator = new Random();
       int i = rask.kistokP;
       synchronized (rask.kistokP) {
			rask.kistokP++;
		}
        int n = i / 2;
        new Automobil(460 + 22*i, 197, 22, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        Random generator = new Random();
        int i = rask.kistokL;
        synchronized (rask.kistokL) {
 			rask.kistokL++;
 		}
        int n = i / 2;
        new Automobil(460 + 22*i, 222, 23, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
        Random generator = new Random();
        int i = rask.kjugD;
		synchronized (rask.kjugD) {
			rask.kjugD++;
		}
        int n = i / 2;
        new Automobil(321, 432 + 21*i, 31, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton18ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
      Random generator = new Random();
      int i = rask.kjugP;
      synchronized (rask.kjugP) {
			rask.kjugP++;
		}
        int n = i / 2;
        new Automobil(295, 432 + 21*i, 32, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton19ActionPerformed

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton20ActionPerformed
      Random generator = new Random();
      int i = rask.kjugL;
      synchronized (rask.kjugL) {
			rask.kjugL++;
		}
        int n = i / 2;
        new Automobil(271, 432 + 21*i, 33, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton20ActionPerformed

    private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton24ActionPerformed
       Random generator = new Random();
       int i = rask.kzapadD;
       synchronized (rask.kzapadD) {
			rask.kzapadD++;
		}
        int n = i / 2;
        new Automobil(50 - 22*i, 293, 41, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton24ActionPerformed

    private void jButton25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton25ActionPerformed
        Random generator = new Random();
        int i = rask.kzapadP;
        synchronized (rask.kzapadP) {
			rask.kzapadP++;
		}
        int n = i / 2;
        new Automobil(50 - 22*i, 268, 42, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton25ActionPerformed

    private void jButton26ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton26ActionPerformed
      Random generator = new Random();
      int i = rask.kzapadL;
      synchronized (rask.kzapadL) {
			rask.kzapadL++;
		}
        int n = i / 2;
        new Automobil(50 - 22*i, 245, 43, rask, generator.nextInt(10) + 1);
    }//GEN-LAST:event_jButton26ActionPerformed

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed
		// TODO add your handling code here:
		rask.tWest = 1;
		rask.tEast = 1;
		rask.tNorth = rask.zelenoL + rask.zelenoP + 20 + 1;
		rask.tSouth = rask.zelenoL + rask.zelenoP + 20 + 1;
		timerNorth.setText("" + rask.tNorth);
		Color c = Color.RED;
		timerNorth.setForeground(c);
		timerSouth.setText("" + rask.tSouth);
		timerSouth.setForeground(c);
		timerEast.setText("" + rask.tEast);
		timerEast.setForeground(c);
		timerWest.setText("" + rask.tWest);
		timerWest.setForeground(c);
		rask.startuj();
	}// GEN-LAST:event_jButton1ActionPerformed

	public JLabel getTSlabel(){
		return timerNorth;
	}
	
	public JLabel getTJlabel(){
		return timerSouth;
	}
	
	public JLabel getTIlabel(){
		return timerEast;
	}
	
	public JLabel getTZlabel(){
		return timerWest;
	}
	public void pocni() {
		rask.pocni();
	}
        
        public JLayeredPane getJLayeredPane(){
            return jLayeredPane1;
        }
        
        public JPanel getJPanel(){
            return jPanel1;
        }
        
	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {

		java.awt.EventQueue.invokeLater(new Runnable() {

			public void run() {
				RaskrsnicaGUI raskrsnica = dohvatiRaskrsnicu();
				raskrsnica.pocni();
				raskrsnica.setVisible(true);
			}
		});
	}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addPesakE1;
    private javax.swing.JButton addPesakE2;
    private javax.swing.JButton addPesakN1;
    private javax.swing.JButton addPesakN2;
    private javax.swing.JButton addPesakS1;
    private javax.swing.JButton addPesakS2;
    private javax.swing.JButton addPesakW1;
    private javax.swing.JButton addPesakW2;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton24;
    private javax.swing.JButton jButton25;
    private javax.swing.JButton jButton26;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel pedestriansEast;
    private javax.swing.JLabel pedestriansNorth;
    private javax.swing.JLabel pedestriansSouth;
    private javax.swing.JLabel pedestriansWest;
    private javax.swing.JLabel semaphoreEastForward;
    private javax.swing.JLabel semaphoreEastLeft;
    private javax.swing.JLabel semaphoreEastRight;
    private javax.swing.JLabel semaphoreNorthForward;
    private javax.swing.JLabel semaphoreNorthLeft;
    private javax.swing.JLabel semaphoreNorthRight;
    private javax.swing.JLabel semaphoreSouthForward;
    private javax.swing.JLabel semaphoreSouthLeft;
    private javax.swing.JLabel semaphoreSouthRight;
    private javax.swing.JLabel semaphoreWestForward;
    private javax.swing.JLabel semaphoreWestLeft;
    private javax.swing.JLabel semaphoreWestRight;
    private javax.swing.JButton tasterJ;
    private javax.swing.JButton tasterS;
    private javax.swing.JButton tasterZ;
    private javax.swing.JButton testerI;
    private javax.swing.JLabel timerEast;
    private javax.swing.JLabel timerNorth;
    private javax.swing.JLabel timerSouth;
    private javax.swing.JLabel timerWest;
    // End of variables declaration//GEN-END:variables
}
